package com.mit.web.business.proxy
{
	import com.mit.web.business.remote.BaseService;
	import com.mit.web.business.remote.IInvokeResponder;
	import com.mit.web.config.Constants;
	import com.mit.web.config.DisplayConfiguration;
	import com.mit.web.vo.manufacture.FactoryVO;
	import com.mit.web.vo.manufacture.MOItemVO;
	import com.mit.web.vo.manufacture.MOVO;
	
	
	public class ManufactureProxy extends BaseService
	{
		private static var me:ManufactureProxy;

		
		public function ManufactureProxy()
		{
			super(Constants.REMOTE_OBJECT_MANUFACTURE);
			if(me != null)
				throw new Error("Only one instance of this class is allowed, use getInstance() insteadof the constructor.");

		}
		
		public static function getInstance():ManufactureProxy{
			if(me == null)
				me = new ManufactureProxy();
			return me;
		} 
		
		public function saveFactory(factory:FactoryVO):IInvokeResponder{
			return invoke("saveFactory", factory);
		}
		
		public function getPagedFactorys(pageNo:int, searchKey:String = null):IInvokeResponder{
			return invoke("retrievePagedFactorys", searchKey, pageNo, DisplayConfiguration.getInstance().PAGE_SIZE);
		}
		
		public function getFactoryCount(searchKey:String = null):IInvokeResponder{
			return invoke("retrieveFactoryCount", searchKey);
		}	
		
		public function getFactoryBasicInfo(searchName:String=null):IInvokeResponder{
			return invoke("retrieveFactoryBasicInfo", searchName);
		}
		
		public function getPagedMO(pageNo:int, code:String=null, factoryId:int=0, dateFrom:Date=null, dateTo:Date=null, state:String = null):IInvokeResponder{
			return invoke("retrievePagedMO", code, factoryId,dateFrom, dateTo, state, pageNo, DisplayConfiguration.getInstance().PAGE_SIZE);
		}
		
		public function getMOCount( code:String=null, factoryId:int=0, dateFrom:Date=null, dateTo:Date=null, state:String = null):IInvokeResponder{
			return invoke("retrieveMOCount", code, factoryId,dateFrom, dateTo, state);
		}
		
		public function saveMO(mo:MOVO):IInvokeResponder{
			return invoke("saveMO", mo);
		}
		
		public function getMO(id:int):IInvokeResponder{
			return invoke("retrieveMO", id);
		}
		
		public function deleteMO(id:int):IInvokeResponder{
			return invoke("deleteMO", id);
		}
		
		public function updateMOState(mo:MOVO):IInvokeResponder{
			return invoke("updateMOState", mo);
		}
	}
}